﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using ProDivingAdmin2salmon14;

namespace Test_ProDivingAdmin2salmon14
{
    [TestFixture]
    class TestContest
    {

        [Test]
        public void TestGenerateValidDives()
        {
            Contest c = new Contest(true, 18, 10,7);

            Assert.IsNotEmpty(Contest.validDives); // Check if dictionary is empty

            Assert.AreEqual(false, Contest.validDives.ContainsKey("101A1"));
        }
        [Test]
        public void TestContestConstruct()
        {
            Contest contest = new Contest(true, 18, 10,7);
            int tempJudgeId = Contest.judgeList[2].ID;
            contest.diverList[5].isInjured = true;

            while (!contest.isDone)
            {
                contest.NextDive();

                if (!contest.isDone && contest.diver != 5)
                {
                    for (int i = 0; i < contest.amountOfJudges; i++)
                    {
                        Contest.judgeScores.Add(tempJudgeId.ToString() + ",1");
                    }
                }

            }

            foreach (var diver in contest.diverList)
            {
                diver.CalculateScore();
            }

            contest.diverList.Sort(delegate(Diver d1, Diver d2)
                                    {
                                        if (d1.totalScore > d2.totalScore)
                                        {
                                            return -1;
                                        }
                                        else if (d1.totalScore < d2.totalScore)
                                        {
                                            return 1;
                                        }
                                        else
                                        {
                                            return 0;
                                        }
                                    });

            foreach (var diver in contest.diverList)
            {
                Console.WriteLine(diver.fullName + " " + diver.totalScore);
            }
            Assert.AreEqual(19.0f, contest.diverList[6].diveList[3].diveScore);
            Assert.AreEqual(7, contest.amountOfJudges);
            Assert.AreEqual(0, contest.diverList[contest.diverList.Count - 1].totalScore);
        }
    }
}
